package com.pig4cloud.pigx.user.mq.config;

import com.pig4cloud.pigx.user.constant.UserMqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 用户模块mq配置
 *
 * @since 2022/12/06 15:28
 */
@Configuration
public class StrategyMqConfig {

	/**
	 * user.fuel.check.queue
	 *
	 * @return {@link FanoutExchange}
	 * @since 2022/8/17 20:39
	 */
	@Bean
	public FanoutExchange userFuelCheckHandleExchange() {
		return new FanoutExchange(UserMqConstant.EXCHANGE_FANOUT_USER_FUEL_CHECK);
	}

	/**
	 * user.fuel.check.queue
	 *
	 * @return {@link Queue}
	 * @since 2022/8/17 20:39
	 */
	@Bean
	public Queue userFuelCheckHandleQueue() {
		return new Queue(UserMqConstant.QUEUE_FANOUT_USER_FUEL_CHECK);
	}

	/**
	 * user.fuel.check.queue
	 *
	 * @param userFuelCheckHandleExchange 交换机
	 * @param userFuelCheckHandleQueue    队列
	 * @return {@link Binding}
	 * @since 2022/8/17 20:43
	 */
	@Bean
	public Binding bindStrategyTaskContractCreate(FanoutExchange userFuelCheckHandleExchange, Queue userFuelCheckHandleQueue) {
		return BindingBuilder.bind(userFuelCheckHandleQueue)
				.to(userFuelCheckHandleExchange);
	}

}
